home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / LINUX / NBD.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  2KB  |  86 lines

  1. #ifndef LINUX_NBD_H
  2. #define LINUX_NBD_H
  3.  
  4. #define NBD_SET_SOCK    _IO( 0xab, 0 )
  5. #define NBD_SET_BLKSIZE    _IO( 0xab, 1 )
  6. #define NBD_SET_SIZE    _IO( 0xab, 2 )
  7. #define NBD_DO_IT    _IO( 0xab, 3 )
  8. #define NBD_CLEAR_SOCK    _IO( 0xab, 4 )
  9. #define NBD_CLEAR_QUE    _IO( 0xab, 5 )
  10. #define NBD_PRINT_DEBUG    _IO( 0xab, 6 )
  11. #define NBD_SET_SIZE_BLOCKS    _IO( 0xab, 7 )
  12.  
  13. #ifdef MAJOR_NR
  14.  
  15. #include <linux/locks.h>
  16. #include <asm/semaphore.h>
  17.  
  18. #define LOCAL_END_REQUEST
  19.  
  20. #include <linux/blk.h>
  21.  
  22. #ifdef PARANOIA
  23. extern int requests_in;
  24. extern int requests_out;
  25. #endif
  26.  
  27. static void 
  28. nbd_end_request(struct request *req)
  29. {
  30. #ifdef PARANOIA
  31.     requests_out++;
  32. #endif
  33.     if (end_that_request_first( req, !req->errors, "nbd" ))
  34.         return;
  35.     end_that_request_last( req );
  36. }
  37.  
  38. #define MAX_NBD 128
  39.  
  40. struct nbd_device {
  41.     int refcnt;    
  42.     int flags;
  43.     int harderror;        /* Code of hard error            */
  44. #define NBD_READ_ONLY 0x0001
  45. #define NBD_WRITE_NOCHK 0x0002
  46. #define NBD_INITIALISED 0x0004
  47.     struct socket * sock;
  48.     struct file * file;         /* If == NULL, device is not ready, yet    */
  49.     int magic;            /* FIXME: not if debugging is off    */
  50.     struct request *head;    /* Requests are added here...            */
  51.     struct request *tail;
  52.     struct semaphore queue_lock;
  53. };
  54. #endif
  55.  
  56. /* This now IS in some kind of include file...    */
  57.  
  58. /* These are send over network in request/reply magic field */
  59.  
  60. #define NBD_REQUEST_MAGIC 0x25609513
  61. #define NBD_REPLY_MAGIC 0x67446698
  62. /* Do *not* use magics: 0x12560953 0x96744668. */
  63.  
  64. /*
  65.  * This is packet used for communication between client and
  66.  * server. All data are in network byte order.
  67.  */
  68. struct nbd_request {
  69.     u32 magic;
  70.     u32 type;    /* == READ || == WRITE     */
  71.     char handle[8];
  72.     u64 from;
  73.     u32 len;
  74. }
  75. #ifdef __GNUC__
  76.     __attribute__ ((packed))
  77. #endif
  78. ;
  79.  
  80. struct nbd_reply {
  81.     u32 magic;
  82.     u32 error;        /* 0 = ok, else error    */
  83.     char handle[8];        /* handle you got from request    */
  84. };
  85. #endif
  86.